﻿using System;
using System.Collections.Generic;
using System.CodeDom.Compiler;

namespace SWF
{
    public struct GotoFrame2 : IAction, IStackManipulator
    {
        public ActionKind ActionId { get { return ActionKind.GotoFrame2; } }
        public uint Version { get { return 4; } }
        public uint Length
        {
            get
            {
                uint len = 4;
                if (SceneBiasFlag) len += 2;
                return len;
            }
        }

        public uint StackPops { get { return 1; } }
        public uint StackPushes { get { return 0; } }
        public int StackChange { get { return -1; } }

        public bool SceneBiasFlag;
        public bool PlayFlag;
        public uint SceneBias;

        public GotoFrame2(SwfReader r)
        {
            r.GetBits(6); // reserved
            SceneBiasFlag = r.GetBit();
            PlayFlag = r.GetBit();
            r.Align();
            if (SceneBiasFlag)
            {
                SceneBias = r.GetUI16();
            }
            else
            {
                SceneBias = 0;
            }
        }

        public void Execute(Runtime.Clip clip, Stack<object> stack, Dictionary<string, object> variables, List<string> constantPool, Dictionary<string, List<IAction>> functionmap)
        {
            //not needed but gotoframe in diff scene
        }
    }
}
